<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page
	import="java.io.InputStreamReader,java.io.IOException,java.io.PrintWriter,java.sql.ResultSet,
java.util.ArrayList,javax.servlet.ServletException,javax.servlet.annotation.WebServlet,javax.servlet.http.HttpServlet,

javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.apache.log4j.Logger,com.grantha.util.DB,com.mysql.jdbc.Connection
,com.mysql.jdbc.PreparedStatement"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="/jsp/header.jsp" />
<%
	String type = request.getParameter("type");
	String title = "", image = "", sqlQuery = "";
	
	if (type == null)
		type = "author";
	if (type.equals(""))
		type = "author";

	if (type.equals("author")) {
		title = "Author";
		image = "Man_Red64.png";
		sqlQuery = "select distinct author from bookregister order by author asc";
	} else if (type.equals("subject")) {
		title = "Subject";
		image = "Flag1RightGreen64.png";
		sqlQuery = "select distinct subject from bookregister order by subject asc";
	} else if (type.equals("status")) {
		title = "Status";
		image = "BulbGrey64.png";
		sqlQuery = "select status author from bookregister order by status asc";
	}
%>
<title>Books By <%=title%></title>
</head>
<body>
	<div id="BooksByAuthor">
		<form action="${WEB_BASE }report/BooksBy<%=title%>" target="_blank">
		<table class="tab">
			<tr>
				<td><img class="img" src="${WEB_BASE}images/<%=image%>"
					alt="bulb" width="72" height="72" id="img" /></td>
				<td><div class="letters">
						Select
						<%=title%>:
					</div></td>
				<td>
						<select name="<%=type%>" id="ComboBox">
							<option value=""></option>
							<%
								try {
									
									ResultSet rs = DB.search(sqlQuery, null);
									
									while (rs.next()) {

										out.write("<option>"+rs.getString(type) + "</option>");

									}
									rs.close();

								}
							
								catch (Exception e) {
									System.err.print("Sorry");
								}
							%>
						</select>
					</td>
				<td>
						<input class="button" type="submit"
							value="Create Report" style="width: 114px" />
					</td>
			</tr>
		</table>
		</form>
	</div>
	<jsp:include page="/jsp/footer.jsp" />
</body>
</html>